<!--
 * @FilePath     : /study_code/layui/11-42.html
 * @Description  : 远程搜索渲染前的配置/处理
 * @Date         : 2025-04-09 11:36:47
 * @Author       : Fang YingGui
 * @LastEditors  : fangyinggui 18715384437@163.com
 * @LastEditTime : 2025-04-09 15:42:31
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>documentName</title>
    <link rel="stylesheet" href="/layui/dist/css/layui.css" />
    <link rel="stylesheet" href="/layui/extends_modules/formSelects-v4/formSelects-v4.css" />
  </head>
  <body>
    <div class="layui-form">
      <select name="city" xm-select="select11" xm-select-search>
        <option value="">请输入值搜索</option>
      </select>
    </div>

    <script src="/layui/dist/layui.js"></script>
    <script>
      layui
        .config({
          base: '/layui/extends_modules/', // 配置 layui 第3方扩展模块存放的基础目录
        })
        .extend({
          formSelects: '/formSelects-v4/formSelects-v4',
        })
        .use(['jquery', 'formSelects'], function () {
          var $ = layui.jquery,
            formSelects = layui.formSelects

          layui.formSelects.config('select11', {
            searchUrl: '/layui/form-selects/search1',

            // ！这里暂时无法运行
            beforeSuccess: function (id, url, searchVal, result) {
              //我要把数据外层的code, msg, data去掉
              result = result.data
              //我要反转name
              $.each(result, function (index, item) {
                item.name && (item.name = item.name.split('').reverse().join(''))
              })
              //然后返回数据
              return result
            },
          })
        })
    </script>
  </body>
</html>
